# -*- coding: utf-8 -*-

from bopress.hook import add_static_path, add_menu_page, add_action

plugin_name = "Static File Demo"
version = "1.0"
description = "演示插件静态资源如何使用的样例"
uri = "http://www.xianduoji.cn"
author = "yezang"
author_uri = "http://www.xianduoji.cn"
__author__ = 'yezang'


def scripts(res, current_screen):
    if current_screen.id == "plugin-static-file-demo":
        res.enqueue_plugin_script(src="staticfiledemo/static/js/jquery.ztree.core.js", ver="3.5.28")


def styles(res, current_screen):
    if current_screen.id == "plugin-static-file-demo":
        res.enqueue_plugin_style(src="staticfiledemo/static/css/zTreeStyle/zTreeStyle.css", ver="3.5.28")


def bo_plugin_load():
    # {{plugin_static_url("staticfiledemo/static/abc.txt", "1.0")}}
    add_static_path("staticfiledemo/static")
    add_menu_page("Plugin Static File Demo", "Plugin Static File Demo", "plugin-static-file-demo", ["read"],
                  "staticfiledemo/tpl/ztree.html")
    add_action("bo_enqueue_styles", styles)
    add_action("bo_enqueue_scripts", scripts)
